package www.openteam.com.presenter.policy;

import java.util.HashMap;
import java.util.List;

import www.openteam.com.base.BasePresenter;
import www.openteam.com.bean.ApprovalStatu;
import www.openteam.com.bean.OrderApproval;
import www.openteam.com.bean.UserSpRight;
import www.openteam.com.contract.policy.CustomOrderApprovalContract;
import www.openteam.com.model.policy.CustomOrderApprovalModel;
import www.openteam.com.mvp.IModel;
import www.openteam.com.ui.policy.CustomOrderApprovalFragment;

/**
 * Created by kylin on 2017/1/11.
 */

public class CustomOrderApprovalPresenter  extends
        BasePresenter<CustomOrderApprovalFragment> implements CustomOrderApprovalContract.CustomOrderApprovalPresenter{
    @Override
    public HashMap<String, IModel> getiModelMap() {
        return loadModelMap(new CustomOrderApprovalModel());
    }

    @Override
    public HashMap<String, IModel> loadModelMap(IModel... models) {
        HashMap<String ,IModel> hashMap = new HashMap<>();
        hashMap.put("queryOrder",models[0]);

        return hashMap;
    }

    @Override
    public void queryOrder(String custorderid, String custid, String orderStatus,
                           long startTime, long endTime,
                           String stype, String moreCom,int userId,String jMark,int PageSize) {
        ((CustomOrderApprovalModel)
                getiModelMap().get("queryOrder"))
                .queryOrder(custorderid, custid, orderStatus, startTime, endTime,stype,moreCom,userId,jMark,PageSize,
                        new CustomOrderApprovalModel.CustomOrderApprovalOnListener() {
                    @Override
                    public void queryCOASuccess(List<OrderApproval.DataEntity> orderApprovals) {
                        getIView().queryCOASuccess(orderApprovals);
                    }

                    @Override
                    public void queryCOAFail(String failMsg) {
                        getIView().queryCOAFail(failMsg);
                    }
                });
    }

    @Override
    public void unapprovalStatu(int id) {
        ( (CustomOrderApprovalModel) getiModelMap().get("queryOrder"))
                .unapprovalStatu(id, new CustomOrderApprovalModel.CustomOrderUOnListener() {
                    @Override
                    public void unApprovalCOASuccess(ApprovalStatu aprovalStatu) {

                                getIView().unApprovalCOSuccess(aprovalStatu);

                    }

                    @Override
                    public void unApprovalCOAFail(String failMsg) {
                                getIView().unApprovalCOFail(failMsg);
                    }
                });
    }

    @Override
    public void approvalStatu(int id) {
        ( (CustomOrderApprovalModel) getiModelMap().get("queryOrder"))
                .approvalStatu(id, new CustomOrderApprovalModel.CustomOrderAOnListener() {
                    @Override
                    public void approvalCOASuccess(ApprovalStatu aprovalStatu) {
                            getIView().approvalCOSuccess(aprovalStatu);
                    }
                    @Override
                    public void approvalCOAFail(String failMsg) {
                        getIView().approvalCOFail(failMsg);
                    }
                });
    }

    @Override
    public void checkLAMStatu(int uid, int rid) {
        ((CustomOrderApprovalModel)getiModelMap().get("queryOrder"))
                .checkIsLAM(uid, rid, new CustomOrderApprovalModel.CustomOrderILAMListener() {
                    @Override
                    public void checkILAMSuccess(UserSpRight userSpRight) {
                            getIView().checkLAMSuccess(userSpRight);
                    }

                    @Override
                    public void checkILAMFail(String failMsg) {
                            getIView().checkLAMFail(failMsg);
                    }
                });
    }
}
